package cn.tedu.ssm.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.SessionCookieConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class CoreInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        Long id = (Long)session.getAttribute("UID");
        if(id == null || id <1){
            response.sendRedirect("/login");
            return false;
        }
        return true;
    }

}
